package com.liguangting.agentsflex.simple;

import com.agentsflex.core.llm.ChatContext;
import com.agentsflex.core.llm.Llm;
import com.agentsflex.core.llm.StreamResponseListener;
import com.agentsflex.core.llm.response.AiMessageResponse;
import com.agentsflex.llm.spark.SparkLlm;
import com.agentsflex.llm.spark.SparkLlmConfig;
import com.liguangting.agentsflex.constant.ApiKeys;

import lombok.extern.slf4j.Slf4j;


/**
 * @author liguangting
 * @date 2024/7/2
 * @description
 */
@Slf4j
public class SparkLlmTest {

    public static void main(String[] args) {
        SparkLlmConfig config = new SparkLlmConfig();
        config.setAppId(ApiKeys.SPARK_APP_ID);
        config.setApiKey(ApiKeys.SPARK_API_KEY);
        config.setApiSecret(ApiKeys.SPARK_API_SECRET);
        config.setVersion("v3.5");

        Llm llm = new SparkLlm(config);
//        String question = "推荐一个杭州好玩的景点";
//        log.info(question);
//        String response = llm.chat(question);
//        log.info(response);
        llm.chatStream("地址：浙江省杭州市西湖区西湖大道1号，按省份、城市、区县、详细地址的json格式返回", new StreamResponseListener<AiMessageResponse>() {

            @Override
            public void onMessage(ChatContext context, AiMessageResponse response) {
                System.out.print(response.getMessage().getContent());
            }
        });
    }
}
